<template>
  <div>
    <a-input placeholder="点击设置初始值" :value="title" @click="() => setDefaultValue()"/>
    <FieldDefaultValueSetter ref="FieldDefaultValueSetter" @ok="handleOK"/>
  </div>
</template>
<script>
import FieldDefaultValueSetter from '@/components/hhd/design/FormAction/FieldDefaultValueSetter.vue';
import {createProps} from '@/utils';

export default {
  name: 'DefaultValueInput',
  components: {FieldDefaultValueSetter},
  props: {
    value: undefined,
    title: undefined,
    defaultValueType: undefined,
    fieldConfig: createProps(Object),
  },
  methods: {
    setDefaultValue() {
      this.$refs.FieldDefaultValueSetter.setData({
        value: this.value,
        title: this.title,
        defaultValueType: this.defaultValueType,
      }, this.fieldConfig);
    },
    handleOK(data) {
      this.$emit('update:title', data.title);
      this.$emit('update:value', data.value);
      this.$emit('update:defaultValueType', data.defaultValueType);
    },
  }
};
</script>